/***************************************************************************
 *   Copyright (C) 2008 by BogDan Vatra                                    *
 *   bogdan@licentia.eu                                                    *
 *                                                                         *
 *   This program is free software: you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/
#ifndef SQLNAVIGATOR_H
#define SQLNAVIGATOR_H

#include <QWidget>
#include <QPushButton>
#include "query.h"

#include "win32def.h"

/**
	@author BogDan Vatra <taipan@omnidatagrup.ro>
*/

class KONTAMABIL_EXPORTS Navigator : public QWidget
{
	Q_OBJECT
	Q_PROPERTY(QString queryName READ queryName WRITE setQueryName)
	Q_PROPERTY(QString deleteMessage READ deleteMessage WRITE setDeleteMessage)

public:
	Navigator(QWidget *parent = 0);
	~Navigator();

	const QString & deleteMessage();
	void setDeleteMessage(const QString & message);

	const QString & queryName();
	void setQueryName(const QString & queryName);

public slots:
	void post();
	void cancel();
	void insert();
	void update();
	void remove();

private:
	void setQuery(SQL::Query * qry);

signals:
	void adauga();
	void modifica();
	void sterge();
	void aplica();
	void renunta();

private slots:
	void disableActions();
	void enableActions();
	void sterg();

protected:
	void showEvent ( QShowEvent * event );

private:
	SQL::Query * m_qry;
	QString m_queryName;
	QString m_deleteMessage;
	QPushButton * m_adauga, * m_modifica, * m_sterge, * m_aplica, * m_renunta;
};

#endif
